//package com.surfilter.sqlopera.opera.insert;
//
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import com.surfilter.funds.task.util.TimeUtil;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.sql.*;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//
//public class MysqlConnectionUtils {
//	private static Logger logger = LoggerFactory.getLogger(MysqlConnectionUtils.class);
//	private static String Driver_class = "com.mysql.cj.jdbc.Driver";
//	private static String url = "jdbc:mysql://202.108.211.109:51024/funds_task";
//	private static String user = "root";
//	private static String password = "rzx@1218!@!#";
//	private static Connection con = null;
//	private static PreparedStatement pstmt = null;
//	private static ResultSet rs = null;
//	private int i;
//
//
//	static {
//		try {
//			Class.forName(Driver_class);
//		} catch (ClassNotFoundException e) {
//			e.printStackTrace();
//		}
//	}
//
//	/*
//	 * 加载驱动
//	 */
//
//	public static void getConnect() {
//		try {
//			con = DriverManager.getConnection(url, user, password);
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		// 判断数据库是否加载成功
//		if (con != null) {
//			System.out.println("数据库加载成功！");
//		} else {
//			System.out.println("数据库加载失败！");
//		}
//	}
//
//	public static void insertFirstRtj(List<MyBean> myBeanList) {
//		String sql = "insert into ytfb_rtj(Tjsj,Tjlx,Ytzl,Sid,dsid,qid,jdid,zl,rzl,zzl,yzl) values (?,?,?,?,?,?,?,?,?,?,?)";
//		if (sql != null) {
//			// 加载驱动
//			getConnect();
//			try {
//				pstmt = con.prepareStatement(sql);
//				for (MyBean myBean : myBeanList) {
//					Object[] object = new Object[11];
//					object[0] = TimeUtil.getnowTime();
//					object[1] = 1;
//					object[2] = myBean.getYtfl();
//					object[3] = myBean.getSid();
//					object[4] = myBean.getDsid();
//					object[5] = myBean.getQid();
//					object[6] = myBean.getJdid();
//					object[7] = myBean.getAllcount();
//					object[8] = myBean.getDaycount();
//					object[9] = myBean.getWeekcount();
//					object[10] = myBean.getMonthcount();
//
//					// 声明一条准备的sql语句
//					// 为Object对象一一赋值
//					for (int i = 0; i < object.length; i++) {
//						pstmt.setObject(i + 1, object[i]);
//						// 批处理sql语句
//					}
//					pstmt.addBatch();
//				}
//				pstmt.executeBatch();
//				System.out.println("批量插入执行完成！");
//			} catch (Exception e) {
//				System.out.println("批量插入数据库报错！");
//				e.printStackTrace();
//			} finally {
//				getClose();
//			}
//		}
//	}
//
//	public void writeYsFinanceType() {
//		List<Map> list_msg = new ArrayList<>();
//		String insertSql = "insert into yswz (sywzwwlj,fxfs,fxsj,dlcyz,ym,sfjrwz) values(?,?,?,?,?,2)";
//		String yswzsql = "select yswzid from yswz where ym ='%s' ";
//		String qrwzsql = "select wzid from qrjrwz where ym ='%s' ";
//		for (Map temp : list_msg) {
//			try {
//				logger.info("开始写入" + temp);
//				String sywzwwlj = (String) temp.get("sywzwwlj");
//				String fxfs = (String) temp.get("fxfs");
//				String fxsj = (String) temp.get("fxsj");
//				String dlcyz = (String) temp.get("dlcyz");
//				String ym = (String) temp.get("ym");
//				String sfjrwz = (String) temp.get("sfjrwz");
//				String[] obj = new String[6];
//				obj[0] = sywzwwlj;
//				obj[1] = fxfs;
//				obj[2] = fxsj;
//				obj[3] = dlcyz;
//				obj[4] = ym;
//				obj[5] = sfjrwz;
//				for (int i = 0; i < obj.length; i++) {
//					pstmt.setObject(i + 1, obj[i]);
//				}
//					String yswzssql = String.format(yswzsql, ym);
//					ResultSet yswzSel = pstmt.executeQuery(yswzssql);
//					String qrwzssql = String.format(qrwzsql, ym);
//					ResultSet qrwzSel = pstmt.executeQuery(qrwzssql);
//					if (qrwzSel.next()) {
//						logger.info("确认金融网站存在，跳过" + temp);
//						continue;
//					}
//					if (yswzSel.next()) {
//						int yswzid = yswzSel.getInt("yswzid");
//						logger.info("疑似金融网站存在" + yswzid);
//					}else {
//						boolean flag = pstmt.execute(insertSql);
//						logger.info("插入疑似网站新数据" + flag);
//					}
//			} catch (Exception e) {
//				System.out.println("解析错误,非法json"+temp);
//			}
//		}
//
//	}
////	public static List<DmbDs> doSql() {
////		List<DmbDs> list = new ArrayList<DmbDs>();
////
////		return list;
////	}
//
//	/*
//	 * 执行sql语句
//	 */
//
////	public static List<MyBean> doSqlMyBean() {
////		String sql = "SELECT t4.ytfl, t4.sid, t4.dsid, t4.qid, t4.jdid, ifnull(t1.daycount, 0) daycount, ifnull(t2.weekcount, 0) weekcount, ifnull(t3.monthcount, 0) monthcount, ifnull(t4.allcount, 0) allcount FROM ( SELECT wj.sjflid AS ytfl, ifnull(jg.sid, 0) AS sid, ifnull(jg.dsid, 0) AS dsid, ifnull(jg.qid, 0) AS qid, ifnull(jg.jdid, 0) AS jdid, count(DISTINCT wj.ptid) AS daycount FROM ( SELECT wzj.ptid AS ptid, wzj.ytfl AS ytfl, wzj.scfxsj AS scfxsj, dj.sjflid AS sjflid FROM ( SELECT cf.ptid ptid, cf.ytfl ytfl, min(cf.scfxsj) scfxsj FROM ( SELECT cm.ptid ptid, cm.ytfl ytfl, cm.scfxsj scfxsj FROM ( SELECT DISTINCT (ptid) AS ptid FROM qrjrwz WHERE yxzt <> 2 AND sfsjwh <> 1 AND ysfjr <> 1 AND sfjs <> 1 AND sczt = 0 AND sfxw = 0 ) ch INNER JOIN ( SELECT DISTINCT ptid, ytfl, scfxsj FROM wz_jryt ) cm ON ch.ptid = cm.ptid UNION SELECT ptid, ytfl, scfxsj FROM gzh_jryt UNION SELECT ptid, ytfl, scfxsj FROM app_jryt ) cf GROUP BY cf.ptid, cf.ytfl ) wzj INNER JOIN ( SELECT d1.flid AS flid3, d2.flid AS flid2, d2.sjflid FROM ( SELECT flid, sjflid FROM dmb_jryt d1 WHERE LEVEL = 3 ) d1 LEFT JOIN dmb_jryt d2 ON d1.sjflid = d2.flid ) dj ON wzj.ytfl = dj.flid3 ) wj INNER JOIN pt ON wj.ptid = pt.ptid LEFT JOIN jg ON jg.jgid = pt.cyjg WHERE pt.sczt = 0 AND pt.xwzt = 1 AND wj.scfxsj BETWEEN ? AND ? GROUP BY wj.sjflid, ifnull(jg.sid, 0), ifnull(jg.dsid, 0), ifnull(jg.qid, 0), ifnull(jg.jdid, 0)) t1 RIGHT JOIN ( SELECT wj.sjflid AS ytfl, ifnull(jg.sid, 0) AS sid, ifnull(jg.dsid, 0) AS dsid, ifnull(jg.qid, 0) AS qid, ifnull(jg.jdid, 0) AS jdid, count(DISTINCT wj.ptid) AS weekcount FROM ( SELECT wzj.ptid AS ptid, wzj.ytfl AS ytfl, wzj.scfxsj AS scfxsj, dj.sjflid AS sjflid FROM ( SELECT cf.ptid ptid, cf.ytfl ytfl, min(cf.scfxsj) scfxsj FROM ( SELECT cm.ptid ptid, cm.ytfl ytfl, cm.scfxsj scfxsj FROM ( SELECT DISTINCT (ptid) AS ptid FROM qrjrwz WHERE yxzt <> 2 AND sfsjwh <> 1 AND ysfjr <> 1 AND sfjs <> 1 AND sczt = 0 AND sfxw = 0 ) ch INNER JOIN ( SELECT DISTINCT ptid, ytfl, scfxsj FROM wz_jryt ) cm ON ch.ptid = cm.ptid UNION SELECT ptid, ytfl, scfxsj FROM gzh_jryt UNION SELECT ptid, ytfl, scfxsj FROM app_jryt ) cf GROUP BY cf.ptid, cf.ytfl ) wzj INNER JOIN ( SELECT d1.flid AS flid3, d2.flid AS flid2, d2.sjflid FROM ( SELECT flid, sjflid FROM dmb_jryt d1 WHERE LEVEL = 3 ) d1 LEFT JOIN dmb_jryt d2 ON d1.sjflid = d2.flid ) dj ON wzj.ytfl = dj.flid3 ) wj INNER JOIN pt ON wj.ptid = pt.ptid LEFT JOIN jg ON jg.jgid = pt.cyjg WHERE pt.sczt = 0 AND pt.xwzt = 1 AND wj.scfxsj BETWEEN ? AND ? GROUP BY wj.sjflid, ifnull(jg.sid, 0), ifnull(jg.dsid, 0), ifnull(jg.qid, 0), ifnull(jg.jdid, 0)) t2 ON t1.ytfl = t2.ytfl AND t1.sid = t2.sid AND t1.dsid = t2.dsid AND t1.qid = t2.qid AND t1.jdid = t2.jdid RIGHT JOIN ( SELECT wj.sjflid AS ytfl, ifnull(jg.sid, 0) AS sid, ifnull(jg.dsid, 0) AS dsid, ifnull(jg.qid, 0) AS qid, ifnull(jg.jdid, 0) AS jdid, count(DISTINCT wj.ptid) AS monthcount FROM ( SELECT wzj.ptid AS ptid, wzj.ytfl AS ytfl, wzj.scfxsj AS scfxsj, dj.sjflid AS sjflid FROM ( SELECT cf.ptid ptid, cf.ytfl ytfl, min(cf.scfxsj) scfxsj FROM ( SELECT cm.ptid ptid, cm.ytfl ytfl, cm.scfxsj scfxsj FROM ( SELECT DISTINCT (ptid) AS ptid FROM qrjrwz WHERE yxzt <> 2 AND sfsjwh <> 1 AND ysfjr <> 1 AND sfjs <> 1 AND sczt = 0 AND sfxw = 0 ) ch INNER JOIN ( SELECT DISTINCT ptid, ytfl, scfxsj FROM wz_jryt ) cm ON ch.ptid = cm.ptid UNION SELECT ptid, ytfl, scfxsj FROM gzh_jryt UNION SELECT ptid, ytfl, scfxsj FROM app_jryt ) cf GROUP BY cf.ptid, cf.ytfl ) wzj INNER JOIN ( SELECT d1.flid AS flid3, d2.flid AS flid2, d2.sjflid FROM ( SELECT flid, sjflid FROM dmb_jryt d1 WHERE LEVEL = 3 ) d1 LEFT JOIN dmb_jryt d2 ON d1.sjflid = d2.flid ) dj ON wzj.ytfl = dj.flid3 ) wj INNER JOIN pt ON wj.ptid = pt.ptid LEFT JOIN jg ON jg.jgid = pt.cyjg WHERE pt.sczt = 0 AND pt.xwzt = 1 AND wj.scfxsj BETWEEN ? AND ? GROUP BY wj.sjflid, ifnull(jg.sid, 0), ifnull(jg.dsid, 0), ifnull(jg.qid, 0), ifnull(jg.jdid, 0)) t3 ON t2.ytfl = t3.ytfl AND t2.sid = t3.sid AND t2.dsid = t3.dsid AND t2.qid = t3.qid AND t2.jdid = t3.jdid RIGHT JOIN ( SELECT wj.sjflid AS ytfl, ifnull(jg.sid, 0) AS sid, ifnull(jg.dsid, 0) AS dsid, ifnull(jg.qid, 0) AS qid, ifnull(jg.jdid, 0) AS jdid, count(DISTINCT wj.ptid) AS allcount FROM ( SELECT wzj.ptid AS ptid, wzj.ytfl AS ytfl, wzj.scfxsj AS scfxsj, dj.sjflid AS sjflid FROM ( SELECT cf.ptid ptid, cf.ytfl ytfl, min(cf.scfxsj) scfxsj FROM ( SELECT cm.ptid ptid, cm.ytfl ytfl, cm.scfxsj scfxsj FROM ( SELECT DISTINCT (ptid) AS ptid FROM qrjrwz WHERE yxzt <> 2 AND sfsjwh <> 1 AND ysfjr <> 1 AND sfjs <> 1 AND sczt = 0 AND sfxw = 0 ) ch INNER JOIN ( SELECT DISTINCT ptid, ytfl, scfxsj FROM wz_jryt ) cm ON ch.ptid = cm.ptid UNION SELECT ptid, ytfl, scfxsj FROM gzh_jryt UNION SELECT ptid, ytfl, scfxsj FROM app_jryt ) cf GROUP BY cf.ptid, cf.ytfl ) wzj INNER JOIN ( SELECT d1.flid AS flid3, d2.flid AS flid2, d2.sjflid FROM ( SELECT flid, sjflid FROM dmb_jryt d1 WHERE LEVEL = 3 ) d1 LEFT JOIN dmb_jryt d2 ON d1.sjflid = d2.flid ) dj ON wzj.ytfl = dj.flid3 ) wj INNER JOIN pt ON wj.ptid = pt.ptid LEFT JOIN jg ON jg.jgid = pt.cyjg WHERE pt.sczt = 0 AND pt.xwzt = 1 GROUP BY wj.sjflid, ifnull(jg.sid, 0), ifnull(jg.dsid, 0), ifnull(jg.qid, 0), ifnull(jg.jdid, 0)) t4 ON t3.ytfl = t4.ytfl AND t3.sid = t4.sid AND t3.dsid = t4.dsid AND t3.qid = t4.qid AND t3.jdid = t4.jdid";
////		Object[] object = null;
////		List<MyBean> list = new ArrayList<MyBean>();
////		// 判断sql语句是否存在
////		if (sql != null) {
////			// 加载驱动
////			getConnect();
////			// 判断object数组是否存在
////			if (object == null) {
////				// 如果不存在，创建一个，防止出现空指针异常
////				object = new Object[6];
////				object[0] = "2017-10-30";
////				object[1] = "2017-10-31";
////				object[2] = "2017-10-24";
////				object[3] = "2017-10-31";
////				object[4] = "2017-09-31";
////				object[5] = "2017-10-31";
////			}
////			try {
////				// 声明一条准备的sql语句
////				pstmt = con.prepareStatement(sql);
////				// 为Object对象一一赋值
////				for (int i = 0; i < object.length; i++) {
////					pstmt.setObject(i + 1, object[i]);
////				}
////				// 执行声明的sql语句
////				pstmt.executeQuery();
////				ResultSet rs2 = getRS();
////
////				while (rs2.next()) {
////					String ytfl = rs2.getString("ytfl");
////					String sid = rs2.getString("sid");
////					String dsid = rs2.getString("dsid");
////					String qid = rs2.getString("qid");
////					String jdid = rs2.getString("jdid");
////					String daycount = rs2.getString("daycount");
////					String weekcount = rs2.getString("weekcount");
////					String monthcount = rs2.getString("monthcount");
////					String allcount = rs2.getString("allcount");
////					MyBean myBean = new MyBean();
////					myBean.setYtfl(Integer.valueOf(ytfl));
////					myBean.setSid(Integer.valueOf(sid));
////					myBean.setDsid(Integer.valueOf(dsid));
////					myBean.setQid(Integer.valueOf(qid));
////					myBean.setJdid(Integer.valueOf(jdid));
////					myBean.setDaycount(Long.valueOf(Double.valueOf(daycount).longValue()));
////					myBean.setWeekcount(Long.valueOf(Double.valueOf(weekcount).longValue()));
////					myBean.setMonthcount(Long.valueOf(Double.valueOf(monthcount).longValue()));
////					myBean.setAllcount(Long.valueOf(Double.valueOf(allcount).longValue()));
////					list.add(myBean);
////				}
////
////			} catch (SQLException e) {
////				e.printStackTrace();
////			} finally {
////				getClose();
////			}
////		}
////		return list;
////	}
//
//	/*
//	 * 获取结果集
//	 */
//	public static ResultSet getRS() {
//		try {
//			// 获取结果集方法
//			rs = pstmt.getResultSet();
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		// 返回结果集
//		return rs;
//	}
//
//	/*
//	 * 获取影响行数
//	 */
//	public int getUpdateCount() {
//		try {
//			i = pstmt.getUpdateCount();
//		} catch (SQLException e) {
//			e.printStackTrace();
//		}
//		// 返回影响行数
//		return i;
//
//	}
//
//	/*
//	 * 关闭方法
//	 */
//	public static void getClose() {
//		// 关闭结果集
//		try {
//			// 结果集关闭方法
//			if (rs != null) {
//				rs.close();
//			}
//		} catch (SQLException e) {
//			e.printStackTrace();
//		} finally {
//			// 关闭声明的sql语句
//			try {
//				// 关闭声明的sql语句方法
//				if (pstmt != null) {
//					pstmt.close();
//				}
//			} catch (SQLException e) {
//				e.printStackTrace();
//			} finally {
//				// 卸载驱动
//				try {
//					// 驱动卸载方法
//					if (con != null) {
//						con.close();
//					}
//				} catch (SQLException e) {
//					e.printStackTrace();
//				}
//			}
//		}
//	}
//
//
//	public static void main(String[] args) {
////		String currentDate = getCurrentDate();
////		System.out.println(currentDate);
////		int quanGuo1 = quanGuo1(0);
////		System.out.println(quanGuo1);
//	}
//
//}
